<template>
  <div class="user-wrapper">
    <div class="content-box">
     <!--  <span class="action">
        <a-icon type="question-circle-o"></a-icon>
      </span> -->
      <!-- <notice-icon class="action"/> -->
      <span class="action other-hover">
        <a-icon style="margin-right: 4px" type="qrcode"/>
        <span>小程序二维码</span>
        <div class="qrocde-img">
          <img :src="qrcode">
        </div>
      </span>
      <span class="action" @click="$store.dispatch('openStateSet',true)">
        <a-icon style="font-size: 18px;margin-right: 6px;vertical-align: -4px;" type="key"></a-icon>
        <span>修改密码</span>
      </span>
      <span class="action">
        <a-avatar class="avatar" size="small" :src="avatar"/>
        <span>
          {{ userInfo.loginName }}
          （{{userInfo.type === 1 ? '管理端':userInfo.type === 2 ? '企业端':userInfo.type === 3 ?'园区端':userInfo.type === 4 ?'HR管理端':'HR企业端'}}）
        </span> 
      </span>
      <span class="action" @click="handleLogout">
        <a-icon style="margin-right: 4px" type="logout"/>
        <span>退出登录</span>
      </span>
     <!--  <a-dropdown>
        <span class="action ant-dropdown-link user-dropdown-menu">
          <a-avatar class="avatar" size="small" :src="avatar"/>
          <span>
            {{ userInfo.loginName }}
            （{{userInfo.type === 1 ? '管理端':userInfo.type === 2 ? '企业端':userInfo.type === 3 ?'园区端':'审计端'}}）
          </span> 
           <span @click="handleLogout">
            <a-icon type="logout"/>
            <span>退出登录</span>
          </span>
        </span>
       
        <a-menu slot="overlay" class="user-dropdown-menu-wrapper">
          <a-menu-item key="0" disabled>
            <router-link :to="{ name: 'center' }">
              <a-icon type="user"/>
              <span>个人中心</span>
            </router-link>
          </a-menu-item>
          <a-menu-item key="1" disabled>
            <router-link :to="{ name: 'settings' }">
              <a-icon type="setting"/>
              <span>账户设置</span>
            </router-link>
          </a-menu-item>
          <a-menu-divider/>
          <a-menu-item key="3">
            <a href="javascript:;" @click="handleLogout">
              <a-icon type="logout"/>
              <span>退出登录</span>
            </a>
          </a-menu-item>
        </a-menu>
      </a-dropdown> -->
    </div>
  </div>
</template>

<script>
import NoticeIcon from '@/components/NoticeIcon'
import qrcode from '@/assets/qrcode.jpg'
import { mapActions, mapGetters } from 'vuex'
export default {
  name: 'UserMenu',
  components: {
    NoticeIcon
  },
  data(){
    return {
      qrcode:qrcode
    }
  },
  computed: {
    ...mapGetters(['userInfo', 'avatar'])

  },
  methods: {
    ...mapActions(['Logout']),
    handleLogout () {
      this.$confirm({
        title: '提示',
        content: '真的要注销登录吗 ?',
        onOk: () => {
          return this.Logout({}).then(() => {
            localStorage.clear();
            setTimeout(() => {
              window.location.reload()
            }, 1000)
           /*  setTimeout(() => {
              window.location.reload()
            }, 16) */
          }).catch(err => {
            this.$message.error({
              title: '错误',
              description: err.message
            })
          })
        },
        onCancel () {}
      })
    }
  }
}
</script>
<style>
  .qrocde-img{
    position: absolute;
    left: -20px;
    top: 62px;
    border: 1px solid #ddd;
    background: #fff;
    padding: 10px;
    width: 170px;
    display: none;
    transition: all 500ms ease;
  }
  .other-hover:hover .qrocde-img{
    display: block;
    transition: all 500ms ease;
  }
  .qrocde-img img{
    display: block;
    max-width: 100%;
  }
</style>